package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

/**
 * 从集合中删除元素
 */
public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c = new ArrayList<>();
//        Collection c = new HashSet();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(1,2));//HashSet是Set集，不能放重复元素
        System.out.println(c);
        Point p = new Point(1,2);
        //remove方法删除集合中与给定元素equals比较为true的元素，重复元素仅删除一次。
        c.remove(p);
        System.out.println(c);

    }
}
